package com.wuye.rcgl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wuye.common.annotation.Log;
import com.wuye.common.core.controller.BaseController;
import com.wuye.common.core.domain.AjaxResult;
import com.wuye.common.enums.BusinessType;
import com.wuye.rcgl.domain.WyFixman;
import com.wuye.rcgl.service.IWyFixmanService;
import com.wuye.common.utils.poi.ExcelUtil;
import com.wuye.common.core.page.TableDataInfo;

/**
 * 维修员Controller
 * 
 * @author wpc
 * @date 2024-11-22
 */
@RestController
@RequestMapping("/rcgl/fixman")
public class WyFixmanController extends BaseController
{
    @Autowired
    private IWyFixmanService wyFixmanService;

    /**
     * 查询维修员列表
     */
    @PreAuthorize("@ss.hasPermi('rcgl:fixman:list')")
    @GetMapping("/list")
    public TableDataInfo list(WyFixman wyFixman)
    {
        startPage();
        List<WyFixman> list = wyFixmanService.selectWyFixmanList(wyFixman);
        return getDataTable(list);
    }


    /**
     * 查询维修员列表
     */
    @PreAuthorize("@ss.hasPermi('rcgl:fixman:list')")
    @GetMapping("/listAll")
    public TableDataInfo listAll(WyFixman wyFixman)
    {
        List<WyFixman> list = wyFixmanService.selectWyFixmanList(wyFixman);
        return getDataTable(list);
    }

    /**
     * 导出维修员列表
     */
    @PreAuthorize("@ss.hasPermi('rcgl:fixman:export')")
    @Log(title = "维修员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WyFixman wyFixman)
    {
        List<WyFixman> list = wyFixmanService.selectWyFixmanList(wyFixman);
        ExcelUtil<WyFixman> util = new ExcelUtil<WyFixman>(WyFixman.class);
        util.exportExcel(response, list, "维修员数据");
    }

    /**
     * 获取维修员详细信息
     */
    @PreAuthorize("@ss.hasPermi('rcgl:fixman:query')")
    @GetMapping(value = "/{fixmanId}")
    public AjaxResult getInfo(@PathVariable("fixmanId") Long fixmanId)
    {
        return success(wyFixmanService.selectWyFixmanByFixmanId(fixmanId));
    }

    /**
     * 新增维修员
     */
    @PreAuthorize("@ss.hasPermi('rcgl:fixman:add')")
    @Log(title = "维修员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WyFixman wyFixman)
    {
        return toAjax(wyFixmanService.insertWyFixman(wyFixman));
    }

    /**
     * 修改维修员
     */
    @PreAuthorize("@ss.hasPermi('rcgl:fixman:edit')")
    @Log(title = "维修员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WyFixman wyFixman)
    {
        return toAjax(wyFixmanService.updateWyFixman(wyFixman));
    }

    /**
     * 删除维修员
     */
    @PreAuthorize("@ss.hasPermi('rcgl:fixman:remove')")
    @Log(title = "维修员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fixmanIds}")
    public AjaxResult remove(@PathVariable Long[] fixmanIds)
    {
        return toAjax(wyFixmanService.deleteWyFixmanByFixmanIds(fixmanIds));
    }
}
